package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author 董代恒
 * @version 1.0
 */
@Component
public class Lift {
    //生命的意义
    private String mean;

    public Lift() {
        System.out.println("1.使用无参构造实例化");
    }

    @Value("生命的意义在于做自己想做的事情")
    public void setMean(String mean) {
        System.out.println("2.通过setter方法进行属性赋值");
        this.mean = mean;
    }

    @PostConstruct
    public void init(){
        System.out.println("3.生命周期初始化方法");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("5.生命周期销毁方法");
    }

    @Override
    public String toString() {
        return "Lift{" +
                "mean='" + mean + '\'' +
                '}';
    }
}
